package com.gqmk.demo.springcloudprovider.controller;

import com.gqmk.demo.springcloudapi.domain.Demo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.Date;

@RestController
@RequestMapping("/provider")
public class ProviderController {
    private int count = 0;

    @GetMapping("demo")
    public Demo getDemo(){
        count++;
        if (count >= 5) {
            throw new RuntimeException("My Demo Provider is error test!"); // 测试Feign中的熔断处理fallback
        }
        return new Demo().setId(count).setName("aaa").setMoney(new BigDecimal(16500)).setCreateDate(new Date()).setIsEnable(true);
    }

}
